package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.service.DelFuncService;
import com.jx.servicrimpl.DelFuncServiceImpl;
/**
 * 删除功能
 * @author zzzzzzz
 *
 */
public class DelFuncController extends HttpServlet{
	DelFuncService dfs=new DelFuncServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//获取数据
		String data=req.getParameter("data");
		String[] ids=data.split(",");
		int j=0;
		for(int i=0;i<ids.length;i++){
			int id=Integer.parseInt(ids[i]);
			boolean result=dfs.delFuncService(id);
			if(result==false){
				break;
			}
			j++;
		}
		PrintWriter pw=resp.getWriter();
		if(j==ids.length){
			pw.write("1");
		}else{
			pw.write("0");
		}
	}
}
